package sistemasdistribuidos;

import classesBase.ModelaTabela;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.RandomAccessFile;
import javax.swing.ListSelectionModel;
import telasMensagem.Bloqueio;

public class ConfiguracoesAgenda extends javax.swing.JDialog {

    ModelaTabela ativo = new ModelaTabela();
    ModelaTabela inativo = new ModelaTabela();
    int flag = 0;

    File txt = new File("C:\\Ziviane10\\Docs\\ConfigAgenda.ini");

    public ConfiguracoesAgenda(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        jSpinnerDas.setEnabled(false);
        jSpinnerAs.setEnabled(false);
        jSpinnerIntervalos.setEnabled(false);
        confAgenda();
        tabela();
    }

    public void confAgenda() {
        try {
            FileReader fr = new FileReader(txt);
            BufferedReader br = new BufferedReader(fr);
            int i = 0;
            while (br.ready()) {
                String line[] = br.readLine().split("=");
                if (i == 0) {
                    jSpinnerDas.setValue(line[1]);
                }
                if (i == 1) {
                    jSpinnerAs.setValue(line[1]);
                }
                if (i == 2) {
                    jSpinnerIntervalos.setValue(line[1]);
                }
                i++;
            }
        } catch (Exception ex) {
            System.out.println(ex);
        }
    }

    public void passarAtivo(int li) {
        ativo.addRow(new String[]{(String) jTableInativos.getValueAt(li, 0),
            (String) jTableInativos.getValueAt(li, 1),
            (String) jTableInativos.getValueAt(li, 2)});
        inativo.removeRow(li);
    }

    public void passarInativo(int li) {
        inativo.addRow(new String[]{(String) jTableAtivos.getValueAt(li, 0),
            (String) jTableAtivos.getValueAt(li, 1),
            (String) jTableAtivos.getValueAt(li, 2)});
        ativo.removeRow(li);
    }

    public void blo(String m) {
        Bloqueio b = new Bloqueio(null, true, m);
        b.setLocationRelativeTo(null);
        b.setVisible(true);
    }

    public void tabela() {
        ativo.setColumnIdentifiers(new String[]{"Código", "Nome", "Telefone"});
        inativo.setColumnIdentifiers(new String[]{"Código", "Nome", "Telefone"});
        jTableAtivos.setModel(ativo);
        jTableInativos.setModel(inativo);
        jTableAtivos.setRowHeight(20);
        jTableInativos.setRowHeight(20);
        jTableAtivos.getColumnModel().getColumn(1).setPreferredWidth(100);
        jTableInativos.getColumnModel().getColumn(1).setPreferredWidth(100);
        ativo.addRow(new String[]{"213", "linha 8", "1284689"});
        ativo.addRow(new String[]{"518", "linha 7", "572534"});
        ativo.addRow(new String[]{"864", "linha 6", "876354"});
        ativo.addRow(new String[]{"650", "linha 5", "890653"});
        inativo.addRow(new String[]{"890", "linha 1", "5632554"});
        inativo.addRow(new String[]{"645", "linha 2", "546882"});
        inativo.addRow(new String[]{"0674", "linha 3", "68034"});
        inativo.addRow(new String[]{"864", "linha 4", "2,15857"});
        //adicionar profissionais nas tabelas em questão
        //seleção da tabelas
        jTableAtivos.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

        jTableInativos.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabelMsg14 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jButtonEditar = new javax.swing.JButton();
        jLabelMsg = new javax.swing.JLabel();
        jLabelMsg1 = new javax.swing.JLabel();
        jSpinnerDas = new javax.swing.JSpinner();
        jLabelMsg4 = new javax.swing.JLabel();
        jSpinnerAs = new javax.swing.JSpinner();
        jSpinnerIntervalos = new javax.swing.JSpinner();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTableAtivos = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTableInativos = new javax.swing.JTable();
        jLabelMsg2 = new javax.swing.JLabel();
        jLabelMsg3 = new javax.swing.JLabel();
        jButtonUmAtivo = new javax.swing.JButton();
        jButtonTudoAtivo = new javax.swing.JButton();
        jButtonTudoInativo = new javax.swing.JButton();
        jButtonUmInativo = new javax.swing.JButton();
        jLabelMsg5 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(255, 102, 0));
        jPanel1.setBorder(javax.swing.BorderFactory.createMatteBorder(3, 3, 3, 3, new java.awt.Color(0, 0, 0)));

        jLabelMsg14.setFont(new java.awt.Font("Segoe UI", 1, 36)); // NOI18N
        jLabelMsg14.setText("Configurações da Agenda");

        jPanel2.setBackground(new java.awt.Color(255, 102, 0));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(0, 0, 0)), "Horário de Funcionamento", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 1, 14), new java.awt.Color(0, 0, 0))); // NOI18N
        jPanel2.setToolTipText("");

        jButtonEditar.setBackground(new java.awt.Color(255, 255, 255));
        jButtonEditar.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
        jButtonEditar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonEditar.setText("Editar");
        jButtonEditar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonEditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEditarActionPerformed(evt);
            }
        });

        jLabelMsg.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg.setText("Das:");
        jLabelMsg.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelMsgMouseClicked(evt);
            }
        });

        jLabelMsg1.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg1.setText("Às:");
        jLabelMsg1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelMsg1MouseClicked(evt);
            }
        });

        jSpinnerDas.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jSpinnerDas.setModel(new javax.swing.SpinnerListModel(new String[] {"06:00", "06:10", "06:20", "06:30", "06:40", "06:50", "07:00", "07:10", "07:20", "07:30", "07:40", "07:50", "08:00", "08:10", "08:20", "08:30", "08:40", "08:50", "09:00", "09:10", "09:20", "09:30", "09:40", "09:50", "10:00", "10:10", "10:20", "10:30", "10:40", "10:50", "11:00", "11:10", "11:20", "11:30", "11:40", "11:50", "12:00", "12:10", "12:20", "12:30", "12:40", "12:50", "13:00", "13:10", "13:20", "13:30", "13:40", "13:50", "14:00", "14:10", "14:20", "14:30", "14:40", "14:50", "15:00", "15:10", "15:20", "15:30", "15:40", "15:50", "16:00", "16:10", "16:20", "16:30", "16:40", "16:50", "17:00", "17:10", "17:20", "17:30", "17:40", "17:50", "18:00", "18:10", "18:20", "18:30", "18:40", "18:50", "19:00", "19:10", "19:20", "19:30", "19:40", "19:50", "20:00", "20:10", "20:20", "20:30", "20:40", "20:50", "21:00", "21:10", "21:20", "21:30", "21:40", "21:50", "22:00", "22:10", "22:20", "22:30", "22:40", "22:50", "23:00"}));

        jLabelMsg4.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg4.setText("Tempo dos Intervalos:");
        jLabelMsg4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelMsg4MouseClicked(evt);
            }
        });

        jSpinnerAs.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jSpinnerAs.setModel(new javax.swing.SpinnerListModel(new String[] {"06:00", "06:10", "06:20", "06:30", "06:40", "06:50", "07:00", "07:10", "07:20", "07:30", "07:40", "07:50", "08:00", "08:10", "08:20", "08:30", "08:40", "08:50", "09:00", "09:10", "09:20", "09:30", "09:40", "09:50", "10:00", "10:10", "10:20", "10:30", "10:40", "10:50", "11:00", "11:10", "11:20", "11:30", "11:40", "11:50", "12:00", "12:10", "12:20", "12:30", "12:40", "12:50", "13:00", "13:10", "13:20", "13:30", "13:40", "13:50", "14:00", "14:10", "14:20", "14:30", "14:40", "14:50", "15:00", "15:10", "15:20", "15:30", "15:40", "15:50", "16:00", "16:10", "16:20", "16:30", "16:40", "16:50", "17:00", "17:10", "17:20", "17:30", "17:40", "17:50", "18:00", "18:10", "18:20", "18:30", "18:40", "18:50", "19:00", "19:10", "19:20", "19:30", "19:40", "19:50", "20:00", "20:10", "20:20", "20:30", "20:40", "20:50", "21:00", "21:10", "21:20", "21:30", "21:40", "21:50", "22:00", "22:10", "22:20", "22:30", "22:40", "22:50", "23:00"}));

        jSpinnerIntervalos.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jSpinnerIntervalos.setModel(new javax.swing.SpinnerListModel(new String[] {"00:10", "00:15", "00:20", "00:30", "00:40", "00:50", "01:00", "01:15", "01:30", "02:00"}));
        jSpinnerIntervalos.setToolTipText("");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelMsg4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jSpinnerIntervalos, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelMsg)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSpinnerDas, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabelMsg1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSpinnerAs, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(8, 8, 8))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(61, 61, 61)
                .addComponent(jButtonEditar, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMsg)
                    .addComponent(jLabelMsg1)
                    .addComponent(jSpinnerDas, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jSpinnerAs, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMsg4)
                    .addComponent(jSpinnerIntervalos, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addComponent(jButtonEditar, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBackground(new java.awt.Color(255, 102, 0));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(0, 0, 0)), "Profissionais Ativos", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 1, 14), new java.awt.Color(0, 0, 0))); // NOI18N
        jPanel3.setToolTipText("");

        jTableAtivos.setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(0, 0, 0), new java.awt.Color(255, 153, 255)));
        jTableAtivos.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTableAtivos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Nome", "Telefone"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableAtivos.setColumnSelectionAllowed(true);
        jTableAtivos.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        jTableAtivos.setRowHeight(25);
        jTableAtivos.getTableHeader().setReorderingAllowed(false);
        jTableAtivos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableAtivosMouseClicked(evt);
            }
        });
        jTableAtivos.addContainerListener(new java.awt.event.ContainerAdapter() {
            public void componentRemoved(java.awt.event.ContainerEvent evt) {
                jTableAtivosComponentRemoved(evt);
            }
        });
        jTableAtivos.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTableAtivosFocusLost(evt);
            }
        });
        jScrollPane1.setViewportView(jTableAtivos);
        jTableAtivos.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

        jTableInativos.setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(0, 0, 0), new java.awt.Color(255, 153, 255)));
        jTableInativos.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTableInativos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Nome", "Telefone"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableInativos.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        jTableInativos.setRowHeight(25);
        jTableInativos.getTableHeader().setReorderingAllowed(false);
        jTableInativos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableInativosMouseClicked(evt);
            }
        });
        jTableInativos.addContainerListener(new java.awt.event.ContainerAdapter() {
            public void componentRemoved(java.awt.event.ContainerEvent evt) {
                jTableInativosComponentRemoved(evt);
            }
        });
        jTableInativos.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTableInativosFocusLost(evt);
            }
        });
        jScrollPane2.setViewportView(jTableInativos);
        jTableInativos.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

        jLabelMsg2.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg2.setText("Em Atividade");
        jLabelMsg2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelMsg2MouseClicked(evt);
            }
        });

        jLabelMsg3.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg3.setText("Fora de Atividade");
        jLabelMsg3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelMsg3MouseClicked(evt);
            }
        });

        jButtonUmAtivo.setBackground(new java.awt.Color(255, 255, 255));
        jButtonUmAtivo.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
        jButtonUmAtivo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Anterior_Icon.png"))); // NOI18N
        jButtonUmAtivo.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonUmAtivo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonUmAtivoActionPerformed(evt);
            }
        });

        jButtonTudoAtivo.setBackground(new java.awt.Color(255, 255, 255));
        jButtonTudoAtivo.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
        jButtonTudoAtivo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Primeiro_Icon.png"))); // NOI18N
        jButtonTudoAtivo.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonTudoAtivo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonTudoAtivoActionPerformed(evt);
            }
        });

        jButtonTudoInativo.setBackground(new java.awt.Color(255, 255, 255));
        jButtonTudoInativo.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
        jButtonTudoInativo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Ultimo_Icon.png"))); // NOI18N
        jButtonTudoInativo.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonTudoInativo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonTudoInativoActionPerformed(evt);
            }
        });

        jButtonUmInativo.setBackground(new java.awt.Color(255, 255, 255));
        jButtonUmInativo.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
        jButtonUmInativo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Proximo_Icon.png"))); // NOI18N
        jButtonUmInativo.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonUmInativo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonUmInativoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 294, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jButtonUmInativo, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jButtonUmAtivo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                                .addComponent(jButtonTudoAtivo, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jButtonTudoInativo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(14, 14, 14)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(86, 86, 86)
                        .addComponent(jLabelMsg2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabelMsg3)
                        .addGap(85, 85, 85))))
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButtonTudoAtivo, jButtonTudoInativo, jButtonUmAtivo, jButtonUmInativo});

        jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jScrollPane1, jScrollPane2});

        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addComponent(jLabelMsg2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addComponent(jButtonTudoAtivo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonUmAtivo, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonUmInativo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonTudoInativo, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(44, 44, 44))))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addComponent(jLabelMsg3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButtonTudoAtivo, jButtonTudoInativo, jButtonUmAtivo, jButtonUmInativo});

        jLabelMsg5.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/confgAgenda.png"))); // NOI18N
        jLabelMsg5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelMsg5MouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(94, 94, 94)
                        .addComponent(jLabelMsg14))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabelMsg5)
                .addGap(34, 34, 34))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addComponent(jLabelMsg14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabelMsg5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEditarActionPerformed
        if (flag == 1) {
            try {
                RandomAccessFile arquivo = new RandomAccessFile("C:\\Ziviane10\\Docs\\ConfigAgenda.ini", "rw");
                arquivo.setLength(0);
                arquivo.close();

                FileWriter escrever = new FileWriter(txt, true);
                BufferedWriter bw = new BufferedWriter(escrever);

                bw.write("HORARIO_INICIAL=" + (String) jSpinnerDas.getValue());
                bw.newLine();
                bw.write("HORARIO_FINAL=" + (String) jSpinnerAs.getValue());
                bw.newLine();
                bw.write("INTERVALO=" + (String) jSpinnerIntervalos.getValue());
                bw.close();

            } catch (Exception ex) {
                System.out.println(ex);
            }

            jButtonEditar.setText("Editar");
            flag = 0;
            jSpinnerDas.setEnabled(false);
            jSpinnerAs.setEnabled(false);
            jSpinnerIntervalos.setEnabled(false);
        } else {
            jButtonEditar.setText("Salvar");
            flag = 1;
            jSpinnerDas.setEnabled(true);
            jSpinnerAs.setEnabled(true);
            jSpinnerIntervalos.setEnabled(true);
        }
    }//GEN-LAST:event_jButtonEditarActionPerformed

    private void jLabelMsgMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelMsgMouseClicked

    }//GEN-LAST:event_jLabelMsgMouseClicked

    private void jLabelMsg1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelMsg1MouseClicked

    }//GEN-LAST:event_jLabelMsg1MouseClicked

    private void jTableAtivosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableAtivosMouseClicked

    }//GEN-LAST:event_jTableAtivosMouseClicked

    private void jTableAtivosComponentRemoved(java.awt.event.ContainerEvent evt) {//GEN-FIRST:event_jTableAtivosComponentRemoved

    }//GEN-LAST:event_jTableAtivosComponentRemoved

    private void jTableAtivosFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTableAtivosFocusLost

    }//GEN-LAST:event_jTableAtivosFocusLost

    private void jTableInativosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableInativosMouseClicked

    }//GEN-LAST:event_jTableInativosMouseClicked

    private void jTableInativosComponentRemoved(java.awt.event.ContainerEvent evt) {//GEN-FIRST:event_jTableInativosComponentRemoved

    }//GEN-LAST:event_jTableInativosComponentRemoved

    private void jTableInativosFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTableInativosFocusLost

    }//GEN-LAST:event_jTableInativosFocusLost

    private void jLabelMsg2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelMsg2MouseClicked

    }//GEN-LAST:event_jLabelMsg2MouseClicked

    private void jLabelMsg3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelMsg3MouseClicked

    }//GEN-LAST:event_jLabelMsg3MouseClicked

    private void jButtonUmAtivoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonUmAtivoActionPerformed
        try {
            passarAtivo(jTableInativos.getSelectedRow());
        } catch (Exception ex) {
            blo("<html>Nenhum profissional selecionado! "
                    + "<br>Por favor, selecione o profissional que "
                    + "deseja deixar inativo!<html>");
            System.out.println(ex);
        }
    }//GEN-LAST:event_jButtonUmAtivoActionPerformed

    private void jButtonTudoAtivoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonTudoAtivoActionPerformed
        try {
            if (jTableInativos.getRowCount() > 0) {
                int linhas = jTableInativos.getRowCount();
                for (int i = 0; i < linhas; i++) {
                    passarAtivo(0);
                }
            }
        } catch (Throwable ex) {
            System.out.println(ex);
        }
    }//GEN-LAST:event_jButtonTudoAtivoActionPerformed

    private void jButtonUmInativoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonUmInativoActionPerformed
        try {
            passarInativo(jTableAtivos.getSelectedRow());
        } catch (Exception ex) {
            blo("<html>Nenhum profissional selecionado! "
                    + "<br>Por favor, selecione o profissional que "
                    + "deseja deixar inativo!<html>");
            System.out.println(ex);
        }
    }//GEN-LAST:event_jButtonUmInativoActionPerformed

    private void jButtonTudoInativoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonTudoInativoActionPerformed
        try {
            if (jTableAtivos.getRowCount() > 0) {
                int linhas = jTableAtivos.getRowCount();
                for (int i = 0; i < linhas; i++) {
                    passarInativo(0);
                }
            }
        } catch (Throwable ex) {
            System.out.println(ex);
        }
    }//GEN-LAST:event_jButtonTudoInativoActionPerformed

    private void jLabelMsg5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelMsg5MouseClicked

    }//GEN-LAST:event_jLabelMsg5MouseClicked

    private void jLabelMsg4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelMsg4MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jLabelMsg4MouseClicked

    public static void main(String args[]) {
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ConfiguracoesAgenda.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ConfiguracoesAgenda.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ConfiguracoesAgenda.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ConfiguracoesAgenda.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                ConfiguracoesAgenda dialog = new ConfiguracoesAgenda(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    public static javax.swing.JButton jButtonEditar;
    public static javax.swing.JButton jButtonTudoAtivo;
    public static javax.swing.JButton jButtonTudoInativo;
    public static javax.swing.JButton jButtonUmAtivo;
    public static javax.swing.JButton jButtonUmInativo;
    public static javax.swing.JLabel jLabelMsg;
    public static javax.swing.JLabel jLabelMsg1;
    private javax.swing.JLabel jLabelMsg14;
    public static javax.swing.JLabel jLabelMsg2;
    public static javax.swing.JLabel jLabelMsg3;
    public static javax.swing.JLabel jLabelMsg4;
    public static javax.swing.JLabel jLabelMsg5;
    private javax.swing.JPanel jPanel1;
    public static javax.swing.JPanel jPanel2;
    public static javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    public static javax.swing.JSpinner jSpinnerAs;
    private javax.swing.JSpinner jSpinnerDas;
    private javax.swing.JSpinner jSpinnerIntervalos;
    public static javax.swing.JTable jTableAtivos;
    public static javax.swing.JTable jTableInativos;
    // End of variables declaration//GEN-END:variables
}
